import React, {useEffect, useState} from 'react'
import {
  Form,
  Button,
  DatePicker,
  Input,
  Modal,
  Select,
  Row,
  Col,
  Upload,
  message,
  TreeSelect,
  ConfigProvider,
  Checkbox,
  Table,
  InputNumber,
  Tag
} from 'antd'
import {getJobByOrgId, findTiaoxinTixiByJobId, getPersonRecord, getComputerSubsidyByOid} from '../service'
import {findItemByTree} from '@/utils/functions'
import {UploadOutlined, SearchOutlined} from '@ant-design/icons';
import moment from 'moment'
import {connect} from 'umi'
import {
  transferTypeList,
  contractTempList,
  contractStatuses,
  applyMannerList,
} from "@/utils/constant";
import SelectUserModal from "@/pages/components/SelectUserModal";
import {getUploadUrl} from "@/utils/upload";

const FormItem = Form.Item;
const Option = Select.Option;
const {TextArea} = Input;

const formLayout = {
  labelCol: {span: 7},
};
const colStyle = {
  xl: 8,
  lg: 8,
  md: 8,
  sm: 8,
  xs: 8,
};

let uploadedFiles = [];

const CreateForm = (props) => {
  const {onSubmit, onCancel, personnel = {}, currentUser = {}, current, visible, pageType} = props;
  const {options = {}} = personnel;
  const {orgTree = [], orgLine = [], orgSystem = [], jobLevel = []} = options;
  const [fileName, setFileName] = useState(null);
  const [fileUploadUrls, setFileUploadUrls] = useState([]);
  const [formTitle, setFormTitle] = useState('新增调动');
  const [operationType, setOperationType] = useState('add');
  const [beforeInfo, setBeforeInfo] = useState(null);
  const [form] = Form.useForm();
  const [userModalVisible, setUserModalVisible] = useState(false);
  const [unitTree, setUnitTree] = useState([]);
  const [jobList, setJobList] = useState([]);
  const [afterOrgTree, setAfterOrgTree] = useState([]);
  const [afterUnitTree, setAfterUnitTree] = useState([]);
  const [afterDepartmentName, setAfterDepartmentName] = useState('');
  const [afterJob, setAfterJob] = useState('');
  const [afterJobLevelType, setAfterJobLevelType] = useState('');
  const [afterJobLevel, setAfterJobLevel] = useState('');
  const [contractInfo, setContractInfo] = useState(null);
  const [showContractInfo, setShowContractInfo] = useState(false);
  const [showAdjustmentSubsidy, setShowAdjustmentSubsidy] = useState(false);
  const [dataSource, setDataSource] = useState([]);

  const fileProps = {
    name: 'file',
    multiple: false,
    action: getUploadUrl(),
    defaultFileList: uploadedFiles,
    data: {name: fileName},
    beforeUpload(file) {
      setFileName(file.name)
    },
    onChange(info) {
      const {status} = info.file;
      if (status === 'done') {
        if (info.file.response.error) {
          message.success(`${info.file.response.error} 。`);
        } else {
          let urls = fileUploadUrls;
          urls.push(info.file.response);
          setFileUploadUrls(urls);
          message.success(`${info.file.name} 文件上传成功。`);
        }
      } else if (status === 'error') {
        message.error(`${info.file.name} 文件上传失败。`);
      }
    },
    onRemove(info) {
      let urls = fileUploadUrls;
      let index = urls.indexOf(info.url);
      if (index > -1)
        urls.splice(index, 1);
      setFileUploadUrls(urls);
    }
  };

  const columns = [
    {
      title: '姓名',
      dataIndex: 'name',
    },
    {
      title: '申请方式',
      dataIndex: 'applyMode',
      render: (text) => text && applyMannerList.find(item => item.value = text).label
    },
    {
      title: '申请时间',
      dataIndex: 'applyDate',
      render: (text) => text && moment(text).format('YYYY-MM-DD')
    },
    {
      title: '申请总金额',
      dataIndex: 'duration',
      render: (text, record) => (text ? parseInt(text) * parseInt(record.monthlyAmount).toFixed(2) : 0)
    },
    {
      title: '每月金额',
      dataIndex: 'monthlyAmount',
    },
    {
      title: '补贴开始时间',
      dataIndex: 'startDate',
      render: (text) => text && moment(text).format('YYYY-MM-DD')
    },
    {
      title: '补贴结束时间',
      dataIndex: 'endDate',
      render: (text) => text && moment(text).format('YYYY-MM-DD')
    },
  ];

  const contractColumns = [
    {title: '原合同主体', dataIndex: 'employerCompany', align: 'center'},
    {
      title: '生效日期', dataIndex: 'contractBeginDate', align: 'center',
      render: (text) => {
        return text !== '-' ? moment(text).format('YYYY-MM-DD') : ''
      }
    },
    {
      title: '终止日期', dataIndex: 'contractEndDate', align: 'center',
      render: (text) => {
        return text !== '-' && text ? moment(text).format('YYYY-MM-DD') : ''
      }
    },
    {
      title: '合同类型', dataIndex: 'beginContractType', align: 'center',
      render: (text) => {
        return contractTempList.find((item) => item.value === parseInt(text))?.label;
      },
    },
    {
      title: '合同状态', dataIndex: 'status', align: 'center',
      render: () => {
        return (<Tag color="green">已生效</Tag>);
      }
    },
  ];

  useEffect(() => {
    const afterItem = findItemByTree(orgTree, current ? parseInt(current.afterOrgId) : 1);
    setUnitTree(afterItem ? afterItem.children : []);
    let data = {
      applyCode: currentUser.usercode,
      applyDepartment: currentUser.department,
      applyUserJob: currentUser.jobname,
      applyUserName: currentUser.name,
      applyDate: moment(),
      endTransferDate: moment('2200-12-31'),
      type: pageType
    };
    if (current && visible) {
      setFormTitle('编辑调动');
      setOperationType('update');
      setBeforeInfo(current);
      if (current.fileUrl) {
        let fileUrlList = current.fileUrl.split(',');
        setFileUploadUrls(fileUrlList);
        fileUrlList.forEach((item, index) => {
          uploadedFiles.push({
            uid: index,
            name: item.split('----')[1],
            status: 'done',
            url: item,
          })
        })
      }
      limitOrgTree(parseInt(current.beforeOrgId));
      setAfterUnitTreeFunction(current.beforeDepartmentId);
      getJobByOrgId(current.afterDepartmentId).then((res) => {
        setJobList(res);
      });

      data = {...data, ...current};
      data.afterOrgId = parseInt(current.afterOrgId);
      data.afterDepartmentId = parseInt(current.afterDepartmentId);
      data.hiredate = moment(current.hireDate);
      data.applyDate = moment(current.createTime);
      data.beforeSystemName = orgSystem.find(item => item.id === current.beforeSystemId)?.name;
      data.afterSystemName = orgSystem.find(item => item.id === current.afterSystemId)?.name;
      data.beforeSubsidyEnd = current.beforeSubsidyEnd && moment(current.beforeSubsidyEnd);
      data.afterSubsidyEnd = current.afterSubsidyEnd && moment(current.afterSubsidyEnd);
      data.afterSubsidyStart = current.afterSubsidyStart && moment(current.afterSubsidyStart);
      if (current.beforeSubsidyId) {
        setShowAdjustmentSubsidy(true);
        data.isAdjustmentSubsidy = 1;
        getComputerSubsidyByOid(current.oid).then(res => {
          setDataSource(res.data);
        });
      } else {
        data.isAdjustmentSubsidy = 0;
      }
    } else {
      setFormTitle('新建调动');
      setOperationType('add');
    }
    form.setFieldsValue(data);
  }, [current, visible]);

  const onFormCancel = () => {
    uploadedFiles = [];
    setFileUploadUrls([]);
    form.resetFields();
    setBeforeInfo(null);
    setDataSource([]);
    onCancel();
  };

  const handleSubmit = async (saveOrAudit) => {
    const fieldsValue = await form.validateFields();
    if (pageType === 2 && fieldsValue.afterOrgId === parseInt(beforeInfo.beforeOrgId)) {
      message.error('单位内部调动请前往单位内部部门直接调动发起');
      return;
    } else if (pageType === 1 && fieldsValue.afterDepartmentId === parseInt(beforeInfo.beforeDepartmentId)) {
      message.error('部门内部平调请前往部门内部调动发起');
      return;
    }
    if (!showAdjustmentSubsidy) {
      fieldsValue.beforeSubsidyEnd = '';
      fieldsValue.beforeSubsidy = '';
      fieldsValue.beforeSubsidyId = '';
      fieldsValue.afterSubsidyEnd = '';
      fieldsValue.afterSubsidyStart = '';
      fieldsValue.afterSubsidy = '';
    }
    onSubmit({
      ...beforeInfo,
      ...fieldsValue,
      url: fileUploadUrls,
      hireDate: fieldsValue.hiredate,
      saveOrAudit: saveOrAudit,
      type: pageType,
      operationType: operationType,
      afterDepartment: afterDepartmentName,
      afterJob: afterJob,
      afterJobLevelType: parseInt(afterJobLevelType),
      afterJobLevel: afterJobLevel,
      transferId: current && current.transferId,
      isAfreshContract:fieldsValue.isAfreshContract?1:0,
      isAdjustmentSubsidy:fieldsValue.isAdjustmentSubsidy?1:0
    });
    form.resetFields();
    setBeforeInfo(null);
    setFileUploadUrls([]);
    uploadedFiles = [];
  };

  const showSelectUserModal = () => {
    setUserModalVisible(true);
  };

  const limitOrgTree = (orgId) => {
    //调动限制公司部门
    if (pageType !== 2) {
      const orgItem = findItemByTree(orgTree, parseInt(orgId));
      setAfterOrgTree([orgItem]);
    } else {
      setAfterOrgTree(orgTree.filter(item => item.value !== parseInt(orgId)));
    }
  };

  const confirmSelectUser = (info) => {
    if (info) {
      let needsUserInfo = {
        beforeDepartment: info[0].unitname,
        beforeDepartmentId: parseInt(info[0].unitId),
        beforeJob: info[0].jobname,
        beforeJobId: info[0].jobId,
        beforeJobLevel: jobLevel.find(item => (item.id === info[0].jobLevelId))?.name,
        beforeJobLevelId: info[0].jobLevelId,
        beforeJobLevelType: info[0].jobLevelType,
        beforeOrg: info[0].orgname,
        beforeOrgId: info[0].orgId,
        name: info[0].name,
        oid: info[0].oid,
        userCode: info[0].code,
        hiredate: moment(info[0].hiredate),
      };
      //调动限制公司部门
      limitOrgTree(info[0].orgId);
      //部门内部调动 锁死调动类型与职级
      if (pageType === 0) {
        needsUserInfo.afterJobLevelId = needsUserInfo.beforeJobLevelId;
        needsUserInfo.transferType = 0;
        for (let i = 0; i < jobLevel.length; i++) {
          let item = jobLevel[i];
          if (item.id === needsUserInfo.beforeJobLevelId) {
            if (item.type === "CODE_MANAGEMENTRANK") {
              setAfterJobLevelType('2');
            } else {
              setAfterJobLevelType('1');
            }
            break;
          }
        }
      }
      setBeforeInfo(needsUserInfo);
      const fieldsValue = form.getFieldsValue();
      findTiaoxinTixiByJobId(info[0].jobId).then(res => {
        if (res.flag) {
          form.setFieldsValue({
            ...fieldsValue,
            ...needsUserInfo,
            beforeSystemName: res.data.C_TIXINAME,
            beforeSystemId: res.data.C_TIXI
          });
        } else {
          message.error(res.error);
        }
      });
      getPersonRecord(needsUserInfo.oid).then(res => {
        setContractInfo(res);
      });
      getComputerSubsidyByOid(needsUserInfo.oid).then(res => {
        setDataSource(res.data);
      });
      setUserModalVisible(false);
    } else {
      message.error('请选择人员!')
    }
  };

  const cancelSelectUser = () => {
    setUserModalVisible(false);
  };

  const onChangeAfterUnitId = (value, options) => {
    setAfterDepartmentName(options[0]);
    getJobByOrgId(value).then((res) => {
      setJobList(res)
    });
    form.setFieldsValue({afterJobId: null})
  };

  /**
   * 设置内部部门内调动部门
   * @param departmentId
   */
  const setAfterUnitTreeFunction = (departmentId) => {
    const depItem = findItemByTree(orgTree, parseInt(departmentId));
    const item = findItemByTree(orgTree, depItem.pareorgId);
    setAfterUnitTree(item ? item.children : []);
  };

  const onChangeOrgId = (value, options) => {
    if (pageType === 0) {
      setAfterUnitTreeFunction(beforeInfo.beforeDepartmentId);
    } else {
      const item = findItemByTree(orgTree, value);
      setUnitTree(item ? item.children : []);
    }
    setJobList([]);
    form.setFieldsValue({afterJobId: null, afterDepartmentId: null})
  };

  const onChangeJobId = (value, options) => {
    const fieldsValue = form.getFieldsValue();
    findTiaoxinTixiByJobId(value).then(res => {
      if (res.flag) {
        form.setFieldsValue({...fieldsValue, afterSystemName: res.data.C_TIXINAME, afterSystemId: res.data.C_TIXI});
      } else {
        message.error(res.error);
      }
    });
  };

  const jobLevelOnChange = (value, options) => {
    setAfterJobLevel(options.children);
    for (let i = 0; i < jobLevel.length; i++) {
      let item = jobLevel[i];
      if (item.id === value) {
        if (item.type === "CODE_MANAGEMENTRANK") {
          setAfterJobLevelType('2');
        } else {
          setAfterJobLevelType('1');
        }
        break;
      }
    }
  };

  const filterOption = (input, option) => {
    return option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
  };

  const changeAfreshContract = (e) => {
    let value = e.target.checked;
    setShowContractInfo(value);
  };

  const isShowSubsidyInfo = (e) => {
    let value = e.target.checked;
    setShowAdjustmentSubsidy(value);
    let restSubsidyInfo = current ?
      {
        beforeSubsidyEnd: current.beforeSubsidyEnd ? moment(current.beforeSubsidyEnd) : null,
        afterSubsidyEnd: current.afterSubsidyEnd ? moment(current.afterSubsidyEnd) : null,
        afterSubsidyStart: current.afterSubsidyStart ? moment(current.afterSubsidyStart) : null,
        afterSubsidy: current.afterSubsidy ? current.afterSubsidy : null
      } : {};
    if (value) {
      if (dataSource.length > 0)
        form.setFieldsValue({
          ...restSubsidyInfo,
          beforeSubsidyEnd: moment(dataSource[0].endDate),
          beforeSubsidy: dataSource[0].monthlyAmount,
          beforeSubsidyId: dataSource[0].id,
        })
    } else {
      form.setFieldsValue({
        beforeEndTime: null,
        beforeSubsidy: null,
        beforeSubsidyId: null,
        afterSubsidyEnd: null,
        afterSubsidyStart: null,
        afterSubsidy: null
      })
    }
  };

  const renderContent = () => {
    return (<>
      <Row gutter={24}>
        <Col span={0}>
          <FormItem name="applyCode" label="申请人工号">
            <Input disabled={true}/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem name="applyUserName" label="申请人" rules={[{required: true, message: '申请人不能为空'}]}>
            <Input disabled={true}/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem name="applyDepartment" label="申请人部门">
            <Input disabled={true}/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem name="applyUserJob" label="申请人职位">
            <Input disabled={true}/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem name="name" label="姓名" rules={[{required: true, message: '姓名不能为空'}]}>
            <Input.Group compact size="large">
              <Input style={{width: '80%', height: '32px', fontSize: '14px', background: '#ffffff'}}
                     placeholder="选择调动员工" value={beforeInfo ? beforeInfo.name : ''} disabled={true}/>
              <Button style={{width: '20%'}} icon={<SearchOutlined/>} onClick={() => showSelectUserModal()}/>
            </Input.Group>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem name="hiredate" label="入职日期">
            <DatePicker disabled={true} className='widthStyle'/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem name="beforeOrg" label="调动前公司">
            <Input disabled={true}/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem name="beforeDepartment" label="调动前部门">
            <Input disabled={true}/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem name="beforeJob" label="调动前岗位">
            <Input disabled={true}/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem name="beforeSystemName" label="调动前体系">
            <Input disabled={true}/>
          </FormItem>
        </Col>
        <Col span={0}>
          <FormItem name="beforeSystemId" label="调动前体系ID">
            <Input disabled={true}/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem name="beforeJobLevel" label="调动前职级">
            <Input disabled={true}/>
          </FormItem>
        </Col>
        <Col {...colStyle}>
          <FormItem name="applyDate" label="申请日期">
            <DatePicker disabled={true} className='widthStyle'/>
          </FormItem>
        </Col>

        <Col {...colStyle}>
          <ConfigProvider>
            <FormItem name="beginTransferDate" label="调动开始日期" rules={[{required: true, message: '调动开始日期不能为空'}]}>
              <DatePicker style={{width: '100%'}}/>
            </FormItem>
          </ConfigProvider>
        </Col>

        <Col {...colStyle}>
          <ConfigProvider>
            <FormItem name="endTransferDate" label="调动结束日期">
              <DatePicker disabled={true} style={{width: '100%'}}/>
            </FormItem>
          </ConfigProvider>
        </Col>

        <Col {...colStyle}>
          <FormItem name="type" label="变动类型" rules={[{required: true, message: '变动类型不能为空'}]}>
            <Select disabled={true} placeholder="请选择" showSearch filterOption={filterOption}>
              <Option value={0} key={0}>部门内部调转</Option>
              <Option value={1} key={1}>单位内部门之间调动</Option>
              <Option value={2} key={2}>跨单位之间调动</Option>
            </Select>
          </FormItem>
        </Col>

        <Col {...colStyle}>
          <FormItem name="afterOrgId" label="调动后公司" rules={[{required: true, message: '调动后公司不能为空'}]}>
            <TreeSelect treeData={afterOrgTree} onChange={onChangeOrgId}/>
          </FormItem>
        </Col>

        <Col {...colStyle}>
          <FormItem name="afterDepartmentId" label="调转后部门" rules={[{required: true, message: '调转后部门不能为空'}]}>
            <TreeSelect treeData={pageType === 0 ? afterUnitTree : unitTree} onChange={onChangeAfterUnitId}/>
          </FormItem>
        </Col>

        <Col {...colStyle}>
          <FormItem name="afterJobId" label="调转后岗位" rules={[{required: true, message: '调转后岗位不能为空'}]}>
            <Select placeholder="请选择" onChange={(value, options) => onChangeJobId(value, options)} showSearch
                    filterOption={filterOption}>
              {jobList.map((item, index) => {
                return (
                  <Option value={item.coidassignedjob} key={index}>
                    {item.cname}
                  </Option>
                )
              })}
            </Select>
          </FormItem>
        </Col>

        <Col {...colStyle}>
          <Form.Item name="afterJobLevelId" label="调动后职级" rules={[{required: true, message: '调动后职级不能为空'}]}>
            <Select disabled={pageType === 0} placeholder="请选择"
                    onChange={(value, options) => jobLevelOnChange(value, options)}
                    showSearch filterOption={filterOption}>
              {
                jobLevel.map((item, index) => {
                  return (
                    <Option value={item.id} key={index}>{item.name}</Option>
                  )
                })
              }
            </Select>
          </Form.Item>
        </Col>

        <Col {...colStyle}>
          <Form.Item name="afterSystemName" label="调动后体系" rules={[{required: true, message: '调动后体系不能为空'}]}>
            <Input disabled={true}/>
          </Form.Item>
        </Col>

        <Col span={0}>
          <Form.Item name="afterSystemId" label="调动后体系Id" rules={[{required: true, message: '调动后体系不能为空'}]}>
            <Input disabled={true}/>
          </Form.Item>
        </Col>

        <Col {...colStyle}>
          <FormItem name="transferType" label="调动类型" rules={[{required: true, message: '调动类型不能为空'}]}>
            <Select disabled={pageType === 0} placeholder="请选择" showSearch filterOption={filterOption}>
              {transferTypeList.filter(item => item.value !== 1).map((item, index) => {
                return (
                  <Option value={item.value} key={index}>
                    {item.label}
                  </Option>
                )
              })}
            </Select>
          </FormItem>
        </Col>
        {
          pageType !== 0 &&
          <>
            <Col span={24}>
              <FormItem style={{marginBottom: 0}}>
                <span style={{marginRight:80}}>原补贴明细信息</span>
                <FormItem name="isAdjustmentSubsidy" valuePropName="checked" noStyle>
                  <Checkbox disabled={!beforeInfo} onChange={isShowSubsidyInfo}>是否调整补贴</Checkbox>
                </FormItem>
              </FormItem>
            </Col>
            <Col span={24} style={{marginBottom: 24}}>
              <Table rowKey='id' dataSource={dataSource} pagination={false} columns={columns}/>
            </Col>
            {
              showAdjustmentSubsidy ?
                <Col span={24}>
                  <Row gutter={24}>
                    {
                      dataSource.length > 0 &&
                      <>
                        <Col {...colStyle}>
                          <FormItem labelCol={{span: 11}} name="beforeSubsidyEnd" label="原补贴结束时间"
                                    rules={[{required: true, message: '原补贴结束时间不能为空'}]}>
                            <DatePicker className='widthStyle'/>
                          </FormItem>
                        </Col>
                        <Col span={0}>
                          <FormItem name="beforeSubsidy" label="原补金额">
                            <InputNumber/>
                          </FormItem>
                        </Col>
                        <Col span={0}>
                          <FormItem name="beforeSubsidyId" label="原补贴id">
                            <Input/>
                          </FormItem>
                        </Col>
                      </>
                    }
                    <Col {...colStyle}>
                      <FormItem labelCol={{span: 11}} name="afterSubsidy" label="调整后每月补贴金额"
                                rules={[{required: true, message: '调整后每月补贴金额不能为空'}]}>
                        <InputNumber style={{width: '100%'}} className='widthStyle' min={0}/>
                      </FormItem>
                    </Col>
                    <Col {...colStyle}>
                      <FormItem labelCol={{span: 11}} name="afterSubsidyStart" label="补贴开始时间"
                                rules={[{required: true, message: '原补贴开始时间不能为空'}]}>
                        <DatePicker className='widthStyle'/>
                      </FormItem>
                    </Col>
                    <Col {...colStyle}>
                      <FormItem labelCol={{span: 11}} name="afterSubsidyEnd" label="补贴结束时间"
                                rules={[{required: true, message: '原补贴结束时间不能为空'}]}>
                        <DatePicker className='widthStyle'/>
                      </FormItem>
                    </Col>
                  </Row>
                </Col> : ''
            }
          </>
        }

        <Col span={24}>
          <FormItem style={{marginBottom: 0}}>
            <span style={{marginRight:80}}>原劳动合同信息</span>
            <FormItem name="isAfreshContract" valuePropName="checked" noStyle>
              <Checkbox disabled={!beforeInfo} onChange={changeAfreshContract}>是否解除原劳动合同</Checkbox>
            </FormItem>
          </FormItem>
        </Col>
        <Col span={24} style={{marginBottom: 24}}>
          <Table rowKey='id' dataSource={contractInfo} pagination={false} columns={contractColumns}/>
        </Col>

        <Col span={24}>调动原因</Col>
        <Col span={24}>
          <FormItem name="reason" label="" rules={[{required: true, message: '调动原因不能为空'}]}>
            <TextArea rows={4}/>
          </FormItem>
        </Col>

        <Col span={24} style={{marginBottom: 15}}>
          <Upload {...fileProps}>
            <Button>
              <UploadOutlined/> 点击上传附件
            </Button>
          </Upload>
        </Col>
      </Row>
    </>)
  };

  const renderFooter = () => {
    return (
      <>
        <Button type="primary" onClick={() => handleSubmit('save')}>保存</Button>
        <Button onClick={() => onFormCancel()}>关闭页面</Button>
      </>
    )
  };

  return (
    <Modal
      width={'80%'}
      destroyOnClose
      title={formTitle}
      visible={visible}
      footer={renderFooter()}
      onOk={handleSubmit}
      onCancel={() => onFormCancel()}
      okText="确认"
      cancelText="取消"
    >
      <Form
        {...formLayout}
        form={form}
        // style={{ paddingTop: '24px' }}
      >
        {renderContent()}
      </Form>

      <SelectUserModal
        selectType={0}
        visible={userModalVisible}
        handleOk={confirmSelectUser}
        handleCancel={cancelSelectUser}
        isOrgGroupFilter={pageType !== 2}
      />
    </Modal>
  )
}


export default connect(({personnel, user}) => ({
  personnel,
  currentUser: user.currentUser,
}))(CreateForm)
